package com.study.signin_demo2.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;


/**
 * @author whx
 * @date 2022/2/23
 */
@Configuration
@MapperScan(basePackages = {"com.study.signin_demo2.mapper"})
public class MybatisPlusConfig {

    /**
     * 旧版开启分页插件
     */
//    @Bean
//    public PaginationInterceptor paginationInnerInterceptor(){
//        return new PaginationInterceptor();
//    }

    /**
     * 新版开启分页插件
     * @return
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
